import Mock from 'mockjs'
import '@/mock/extend'
import {parseUrlParams} from '@/utils/request'
const Random = Mock.Random;
const source={
  id:12222,
  terminalName:'终端名称',
  terminalCode:'终端编码',
  terminalNumber:'终端号码',
  terminalType:1,
  terminalModel:0,
  subscribeTopic:'订阅主题',
  publishTopic:1,
  list:[{
    sensorName:'密度',
    configuration:true,
    show:false
  },{
    sensorName:'运动粘度（40℃）',
    configuration:true,
    show:false
  },{
    sensorName:'含水量',
    configuration:false,
    show:true
  },{
    sensorName:'含水率',
    configuration:true,
    show:true
  },{
    sensorName:'介电常数',
    configuration:true,
    show:true
  },{
    sensorName:'磨损颗粒/颗粒污染度',
    configuration:true,
    show:true
  }]
}
const source2=Mock.mock({
  'id': 1,
  'deviceName': () => Random.ctitle(2, 4), // 随机生成设备名称
  'alertTitle': () => Random.ctitle(5, 10), // 随机生成预警标题
  'alertContent': () => Random.cparagraph(2, 4), // 随机生成预警内容
  'alertTime': () => Random.datetime(), // 随机生成预警时间
  'priority|1': ['高', '中', '低'], // 随机选择优先级
  'confirmStatus|1': ['已确认', '未确认'], // 随机选择确认状态
  'recoverNormal|1': ['已恢复', '未恢复'], // 随机选择恢复状态
  'faultSource': () => Random.cword(2, 4), // 随机生成故障来源
  'faultType': () => Random.cword(2, 4), // 随机生成故障类型
  'deviceAge': () => Random.integer(1, 10), // 随机生成设备年龄
  'componentPart': () => Random.cword(2, 4), // 随机生成所属部件
  'faultPhenomenon': () => Random.cparagraph(2, 4), // 随机生成故障现象
  'solutionMethod': () => Random.cparagraph(2, 4), // 随机生成解决方案
  'supplementaryExplanation': () => Random.cparagraph(2, 4) // 随机生成补充说明
});
Mock.mock(RegExp(`${process.env.VUE_APP_API_BASE_URL}/detials` + '.*'),'get', ({url}) => {
  const params = parseUrlParams(decodeURI(url))
  let {type} = params
  console.log(url)
  return {
    code: 0,
    message: 'success',
    data:type==1? source:source2
  }
})
